<html xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:t="http://myfaces.apache.org/tomahawk"
      xmlns:v="http://corejsf.com/validator">

    <f:view>
        <f:loadBundle var="text" basename="#{exchangeRateForm.bundleName}"/>
        <head>
            <title>#{text['exchangeRateDetail.title']}</title>
            <meta name="heading" content="#{text['exchangeRateDetail.heading']}"/>
            <meta name="menu" content="CatalogsMenu"/>
        </head>

        <div class="separator"></div>

        <h:form id="exchangeRateForm">
            <h:inputHidden value="#{exchangeRateForm.exchangeRate.id}" id="id"/>

            <h:panelGrid columns="3">

                <h:panelGroup styleClass="buttonBar right">
                    <h:commandButton value="#{text['button.save']}" action="#{exchangeRateForm.save}" id="save" styleClass="button"/>
                    <c:if test="${not empty exchangeRateForm.exchangeRate.id}">
                        <h:commandButton value="#{text['button.delete']}" action="#{exchangeRateForm.delete}"
                                         id="delete" styleClass="button"/>
                    </c:if>
                    <h:commandButton value="#{text['button.cancel']}" action="cancel" immediate="true"
                                     id="cancel" styleClass="button"/>
                </h:panelGroup>
                <h:outputText/><h:outputText/>

                <h:panelGroup styleClass="info">
                    <c:choose>
                        <c:when test="${param.from == 'list' or empty exchangeRateForm.exchangeRate.id}">
                            <h:outputText value="#{text['exchangeRateDetail.admin.message']}"/>
                        </c:when>
                        <c:otherwise><h:outputText value="#{text['exchangeRateDetail.message']}"/></c:otherwise>
                    </c:choose>
                </h:panelGroup>
                <h:outputText/><h:outputText/>

                <h:panelGroup>
                    <div>
                        <div class="left">
                            <h:outputLabel styleClass="desc" for="date" value="#{text['exchangeRate.date']}"/>
                            <t:inputCalendar id="date" value="#{exchangeRateForm.exchangeRate.date}" renderAsPopup="true"
                                             popupDateFormat="dd/MM/yyyy" popupTodayString="Hoy es "
                                             popupWeekString="Semana" lang="es" required="true">
                                <f:convertDateTime pattern="dd/MM/yyyy"/>
                            </t:inputCalendar>
                            <t:message for="date" styleClass="fieldError"/>
                        </div>
                        <div>
                            <h:outputLabel styleClass="desc" for="type" value="#{text['exchangeRate.type']}"/>
                            <h:selectOneMenu value="#{exchangeRateForm.stType}" id="type" styleClass="select" required="true">
                                <f:selectItem itemLabel="DIARIA" itemValue="DIARIA"/>
                                <f:selectItem itemLabel="MENSUAL" itemValue="MENSUAL"/>
                                <f:selectItem itemLabel="PAGADA" itemValue="ANUAL"/>
                            </h:selectOneMenu>
                            <t:message for="type" styleClass="fieldError"/>
                        </div>
                    </div>
                </h:panelGroup>
                <h:outputText/><h:outputText/>

                <h:panelGroup>
                    <div>
                        <div class="left">
                            <h:outputLabel styleClass="desc" for="fromCurrency" value="#{text['exchangeRate.fromCurrency']}"/>
                            <h:inputText value="#{exchangeRateForm.local.description}" disabled="true"/>
                            <!--h:selectOneMenu value="#{exchangeRateForm.exchangeRate.fromCurrency}" id="fromCurrency" styleClass="select" required="true">
                                <t:selectItems value="#{exchangeRateForm.currencies}" var="currency" itemLabel="#{currency.description}" itemValue="#{currency}"/>
                                <f:converter converterId="objconverter"/>
                            </h:selectOneMenu>
                            <t:message for="fromCurrency" styleClass="fieldError"/-->
                        </div>
                        <div>
                            <h:outputLabel styleClass="desc" for="toCurrency" value="#{text['exchangeRate.toCurrency']}"/>
                            <h:selectOneMenu value="#{exchangeRateForm.exchangeRate.toCurrency}" id="toCurrency" styleClass="select" required="true">
                                <t:selectItems value="#{exchangeRateForm.currencies}" var="currency" itemLabel="#{currency.description}" itemValue="#{currency}"/>
                                <f:converter converterId="objconverter"/>
                            </h:selectOneMenu>
                            <t:message for="toCurrency" styleClass="fieldError"/>
                        </div>
                    </div>
                </h:panelGroup>
                <h:outputText/><h:outputText/>

                <h:outputLabel for="rate" styleClass="desc" value="#{text['exchangeRate.rate']}"/>
                <t:message for="rate" styleClass="fieldError"/>
                <h:inputText value="#{exchangeRateForm.exchangeRate.rate}" id="rate" required="true" styleClass="text large">
                    <v:commonsValidator client="true" type="required" arg="#{text['exchangeRate.rate']}"/>
                </h:inputText>
            </h:panelGrid>
        </h:form>

        <script type="text/javascript">
            Form.focusFirstElement($('exchangeRateForm'));
            highlightFormElements();
        </script>
    </f:view>
</html>